package com.newyulong.implatform.activity;

import com.newyulong.implatform.R;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;

public class VasSearchActivity extends BaseActivity{

	private EditText etSearch;
	private ImageView ivDelIcon;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setView(R.layout.vas_search);
		setTitleBar(R.drawable.btn_back_selector, "返回", -1, "");
		SetTitle("增值业务搜索");
		
		findViews();
		initRes();
		setValues();
		setListeners();
		
		
		
	}
	
	private void setListeners() {
		etSearch.addTextChangedListener(new TextWatcher() {
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {}
			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {}
			@Override
			public void afterTextChanged(Editable s) {
				if(etSearch.getText().length()>0){
					ivDelIcon.setVisibility(View.VISIBLE);
				} else {
					ivDelIcon.setVisibility(View.INVISIBLE);
				}
			}
		});
		
		ivDelIcon.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				etSearch.setText("");
			}
		});
		
		
	}

	private void setValues() {
		// TODO Auto-generated method stub
		
	}

	private void initRes() {
		// TODO Auto-generated method stub
		
	}

	private void findViews() {
		etSearch = (EditText) findViewById(R.id.et_search);
		ivDelIcon = (ImageView) findViewById(R.id.iv_search_del);
		
	}

	@Override
	protected void HandleTitleBarEvent(int buttonId) {
		if(buttonId == 0 ){
			finish();
		} else if(buttonId == 1){
			
		}
		
	}

}
